#!/bin/bash

#Panel orientation setup tool for the Merry XFMas theme
#By ratsrats

configfile=$HOME/.config/gtk-3.0/gtk.css

read -a panelsettings<<<$(zenity --forms --title="Tweak panel settings" --text="Enter the identifier of the widgets you would like to set up an orientation profile for" --add-combo="Panel orientation" --combo-values="bottom|top|left|right" --add-entry="Applications menu" --add-entry="Whisker menu" --add-entry="Trash applet" --add-entry="System load monitor" --add-entry="Task list" --add-entry="Directory menu" --add-entry="Show desktop widget" --add-entry="Window menu applet" --add-entry="PulseAudio mixer" --add-entry="Keyboard layout widget" --add-entry="Global menu" --add-entry="Actions widget" --add-entry="Clock" --add-entry="System tray" --add-entry="Power manager applet" --separator=" ")

if [[ -n ${panelsettings[0]} ]] ; then

	if [[ -a $configfile ]] ; then
		rm $configfile;
	fi
	if ! [[ -h $HOME/.config/gtk-3.0/asset ]]; then
		ln -s $HOME/.themes/Merry\ XFMas\ GTK/gtk-3.0/asset $HOME/.config/gtk-3.0/asset
	fi
	case ${panelsettings[0]} in ( top | right | left ) 
		sed -e s/\$a/-${panelsettings[1]}/ -e s/\$b/-${panelsettings[2]}/ -e s/\$c/-${panelsettings[3]}/ -e s/\$d/-${panelsettings[4]}/ -e s/\$e/-${panelsettings[5]}/ -e s/\$f/-${panelsettings[6]}/ -e s/\$g/-${panelsettings[7]}/ -e s/\$h/-${panelsettings[8]}/ -e s/\$i/-${panelsettings[9]}/ -e s/\$j/-${panelsettings[10]}/ -e s/\$j/-${panelsettings[11]}/ -e s/\$k/-${panelsettings[12]}/ -e s/\$l/-${panelsettings[13]}/ -e s/\$m/-${panelsettings[14]}/ -e s/\$n/-${panelsettings[15]}/ -e s/\$o/-${panelsettings[16]}/ ./panel-profile-${panelsettings[0]}.css>$configfile;;
	esac

	case ${panelsettings[0]} in ( top | right )
		sed r ./whiskermenu-${panelsettings[0]}.css $configfile>$configfile.new
		cp $configfile.new $configfile; rm $configfile.new;&
	esac
fi